{% extends 'base.html' %}

{% block content %}
<div class="card mx-auto" style="width: 400px;">
  <div class="card-body">
    <h1 class="card-title text-center">添加学生</h1>
    <form method="post">
      {% csrf_token %}
      <div class="form-group">
        <label for="name">姓名:</label>
        <input type="text" class="form-control" name="name" required>
      </div>
      <div class="form-group">
        <label for="sex">性别:</label>
        <select class="form-control" name="sex" id="sex">
          <option value="男生">男生</option>
          <option value="女生">女生</option>
        </select>
      </div>
      <div class="form-group">
        <label for="age">年龄:</label>
        <input type="number" class="form-control" name="age" required>
      </div>
      <div class="form-group">
        <label for="classes">班级:</label>
        <select class="form-control" name="classes" id="classes">
          {% for class_obj in classes %}
          <option value="{{ class_obj.id }}">{{ class_obj.name }}</option>
          {% endfor %}
        </select>
      </div>
      <button type="submit" class="btn btn-primary">添加学生</button>
    </form>
    
  </div>
  <button class="btn btn-secondary mt-2" onclick="location.href='{% url 'student_list' %}'">返回学生列表</button>
</div>

{% endblock %}
